package cn.deepbit.service.thingsboard.controller;

import org.anyline.thingsboard.util.ThingsBoardClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class Config {

    @Value("${thingsboard.host}")
    private String thingsboardHost;
    @Value("${thingsboard.account}")
    private String thingsboardAccount;
    @Value("${thingsboard.password}")
    private String thingsboardPassword;

    @Bean
    public ThingsBoardClient thingsboardClient(){
        try {
            ThingsBoardClient client = new ThingsBoardClient(thingsboardHost);
            client.login(thingsboardAccount, thingsboardPassword);
            return client;
        }catch (Exception e){
            return null;
        }
    }
}
